package com.ecommerce.dal.entity;
// Generated May 3, 2013 3:35:49 PM by Hibernate Tools 3.6.0

import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

/**
 * Client generated by hbm2java
 */
@Entity
@Table(name = "client",  uniqueConstraints = @UniqueConstraint(columnNames = "MEMBERSHIP_CARD_ID"))
@PrimaryKeyJoinColumn(name="CLIENT_ID")
public class Client extends User implements java.io.Serializable {

	private long clientId;
	private MembershipCard membershipCard;
	private Company company;
	private Rank rank;
	private User user;
	private int state;
	private boolean sponsor;
	private boolean verified;
	private Set<ClientHistory> clientHistories = new HashSet<ClientHistory>(0);
	private Set<Item> items = new HashSet<Item>(0);
	private Set<Category> categories = new HashSet<Category>(0);

	public Client() {
	}

	public Client(Company company, Rank rank, User user, int state,
			boolean sponsor, boolean verified) {
		this.company = company;
		this.rank = rank;
		this.user = user;
		this.state = state;
		this.sponsor = sponsor;
		this.verified = verified;
	}

	public Client(MembershipCard membershipCard, Company company, Rank rank,
			User user, int state, boolean sponsor, boolean verified,
			Set<ClientHistory> clientHistories, Set<Item> items,
			Set<Category> categories) {
		this.membershipCard = membershipCard;
		this.company = company;
		this.rank = rank;
		this.user = user;
		this.state = state;
		this.sponsor = sponsor;
		this.verified = verified;
		this.clientHistories = clientHistories;
		this.items = items;
		this.categories = categories;
	}

//	@GenericGenerator(name = "generator", strategy = "foreign", parameters = @Parameter(name = "property", value = "user"))
//	@Id
//	@GeneratedValue(generator = "generator")
//	@Column(name = "CLIENT_ID", unique = true, nullable = false)
//	public long getClientId() {
//		return this.clientId;
//	}
//
//	public void setClientId(long clientId) {
//		this.clientId = clientId;
//	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "MEMBERSHIP_CARD_ID", unique = true)
	public MembershipCard getMembershipCard() {
		return this.membershipCard;
	}

	public void setMembershipCard(MembershipCard membershipCard) {
		this.membershipCard = membershipCard;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "COMPANY_ID", nullable = false)
	public Company getCompany() {
		return this.company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "RANK_RANK_ID", nullable = false)
	public Rank getRank() {
		return this.rank;
	}

	public void setRank(Rank rank) {
		this.rank = rank;
	}

	@OneToOne(fetch = FetchType.LAZY)
	@PrimaryKeyJoinColumn
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "STATE", nullable = false)
	public int getState() {
		return this.state;
	}

	public void setState(int state) {
		this.state = state;
	}

	@Column(name = "SPONSOR", nullable = false)
	public boolean isSponsor() {
		return this.sponsor;
	}

	public void setSponsor(boolean sponsor) {
		this.sponsor = sponsor;
	}

	@Column(name = "VERIFIED", nullable = false)
	public boolean isVerified() {
		return this.verified;
	}

	public void setVerified(boolean verified) {
		this.verified = verified;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "client")
	public Set<ClientHistory> getClientHistories() {
		return this.clientHistories;
	}

	public void setClientHistories(Set<ClientHistory> clientHistories) {
		this.clientHistories = clientHistories;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "client")
	public Set<Item> getItems() {
		return this.items;
	}

	public void setItems(Set<Item> items) {
		this.items = items;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "client_category",  joinColumns = { @JoinColumn(name = "CLIENT_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "CATEGORY_ID", nullable = false, updatable = false) })
	public Set<Category> getCategories() {
		return this.categories;
	}

	public void setCategories(Set<Category> categories) {
		this.categories = categories;
	}

}
